import Vue from 'vue'
import VueRouter from 'vue-router'
import HeaderBar from '../components/HeaderBar.vue'
import Home from '../components/home/Home.vue'
import Notification from '../components/home/Notification.vue'
import IntroPanel from '../components/home/IntroPanel.vue'
import Sys from '../components/sys/Sys.vue'
import SysPanel from '../components/sys/SysPanel.vue'
import FootBar from '../components/FooterBar.vue'
import Users from '../components/sys/Users.vue'
import EditUser from '../components/sys/EditUser.vue'
import Register from '../components/profile/Register.vue'
import RegisterPanel from '../components/profile/RegisterPanel.vue'
import Login from '../components/Login.vue'
import Cart from '../components/cart/Cart'
import Product from '../components/product/Product.vue'
import BoatManage from '../components/product/BoatManage.vue'
import BoatAdd from '../components/product/BoatAdd.vue'
import ProdBoatDetail from '../components/product/BoatDetail.vue'
import ProductPanel from '../components/product/ProductPanel.vue'
import HotelManage from '../components/product/HotelManage.vue'
import FlightManage from '../components/product/FlightManage.vue'
import CarManage from '../components/product/CarManage.vue'

Vue.use(VueRouter)

export default new VueRouter({
  scrollBehavior (to, from, savedPosition) {
    if (to.hash) {
      return {
        selector: to.hash
      }
    }
  },
  routes: [
    {
      path: '/',
      name: 'Home',
      components: {
        default: Home,
        header_bar: HeaderBar,
        no: Notification,
        intro_panel: IntroPanel,
        foot_bar: FootBar
      }
    },
    {
      path: '/sys',
      name: 'Sys',
      components: {
        default: Sys,
        header_bar: HeaderBar,
        sys_panel: SysPanel,
        foot_bar: FootBar
      },
      children: [
        {
          path: 'users',
          component: Users
        },
        {
          name: 'editUser',
          path: 'edituser',
          component: EditUser
        }
      ]
    },
    {
      path: '/product',
      name: 'Product',
      components: {
        default: Product,
        header_bar: HeaderBar,
        product_panel: ProductPanel,
        foot_bar: FootBar
      },
      children: [
        {
          path: 'boat',
          component: BoatManage
        },
        {
          path: 'boat_create',
          component: BoatAdd
        },
        {
          name: 'viewBoat',
          path: 'boat_detail/:boatId',
          component: ProdBoatDetail
        },
        {
          path: 'car',
          component: CarManage
        },
        {
          path: 'hotel',
          component: HotelManage
        },
        {
          path: 'flight',
          component: FlightManage
        }
      ]
    },
    {
      path: '/profile/register',
      name: 'Register',
      components: {
        default: Register,
        register_panel: RegisterPanel
      }
    },
    {
      path: '/login',
      components: {
        default: Login
      }
    },
    {
      path: '/cart',
      name: 'Cart',
      components: {
        default: Cart,
        header_bar: HeaderBar,
        foot_bar: FootBar
      }
    }
  ]
})
